import {request} from "@/api";
import type {data2, Request, tree, treeList} from "@/api/home/login/loginData";
import type {LocationQueryValue} from "vue-router";


//登录请求
const getlogin = function (data: data2) {
    return request({method: 'post', url: '/student/login', data: data})
}


//树洞发布请求
const addTree = function (data: tree) {
    return request({method: 'post', url: '/treeHole/hole/add', data: data})
}


//查看树洞列表
const showTree = function () {
    return request({method: 'get', url: '/treeHole/hole/list'})
}

//查看树洞详情信息
const treeMessae = function (id: any) {
    return request({method: 'get', url: `/treeHole/hole/details/${id}`})
}

//删除树洞的按钮请求
const deleteTree = function (id: any) {
    return request({method: 'post', url: '/treeHole/hole/delete', data: id})
}

//获取学生用户信息
const getInfo = function () {
    return request({method: 'get', url: '/system/student/info'})
}


//修改学生信息
const reviseInfo = function (data: string) {
    return request({method: 'post', url: '/system/student/edit', data: data})
}
// 获取验证码
const getCaptcha = function (data: string) {
    return request({method: 'post', url: '/student/sendSms', data: data})
}
//修改学生密码
const revisePassword = function (data: Request) {
    return request({
        method: 'post', url: '/system/student/editPassword', data: data, config: {
            headers: {
                "Content-Type": 'multipart/form-data'
            }
        }
    })
}

//显示测评列表选项
const evaluationList = function (data: treeList) {
    return request({method: 'get', url: '/evaluation/student/list', data: data})
}

//跳转列表详情
const evaluationDetail = function (id: any) {
    return request({method: 'get', url: `/evaluation/student/test/${id}`})
}
//显示系统消息列表
const systemList = function (id: any) {
    return request({method: 'get', url: `/system/list/list/${id}`, data: {pageNumber: 1, pageSize: 20}})
}
//选择完提交测评 结果
const evaluationSubmit = function (data: {
    studentId: string;
    ids: any[];
    assessmentId: string | null | LocationQueryValue[]
}) {
    return request({method: 'post', url: '/evaluation/student/submit', data: data})
}
//查看测评的结果 列表
const evaluationOutcome = function (data: { studentId: number; pageSize: number; pageNum: number }) {
    return request({method: "get", url: '/evaluation/student/record', data: data})
}

//跳转系统消息列表详情
const systemlistDetail = function (id: any) {
    return request({method: 'get', url: `/system/message/${id}`})
}

//更新 系统消息为已读 （小红点）
const readedMessage = function (data: any) {
    return request({method: 'post', url: "/system/list/update", data: data})
}
// 修改学生头像
const reviseHead = function (data: any) {
    const formData = new FormData();
    formData.append("avatar", data)
    return request({
        method: 'post', url: '/system/student/avatar', data: formData, config: {
            headers: {
                "Content-Type": 'multipart/form-data'
            }
        }
    })
}


//未读消息统计
const readNum = function (receiverId: any) {
    return request({method: 'get', url: `/system/list/unreadCount/${receiverId}`})
}
export {
    getlogin,
    addTree,
    showTree,
    treeMessae,
    deleteTree,
    getInfo,
    reviseInfo,
    revisePassword,
    evaluationList,
    systemList,
    evaluationDetail,
    evaluationSubmit,
    evaluationOutcome,
    systemlistDetail,
    readedMessage,
    reviseHead,
    readNum,
    getCaptcha
} //导出